package com.brillilab.service.core.lab.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.lab.LabExpireJobMapper;
import com.brillilab.domain.po.lab.LabExpireJob;
import com.brillilab.service.core.lab.ILabExpireJobService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  实验室过期定时任务
 * </p>
 *
 * @author WuMenghao
 * @since 2019-09-29
 */
@Service
@Transactional
public class LabExpireJobServiceImpl implements ILabExpireJobService {

    @Resource
    private LabExpireJobMapper labExpireJobMapper;

    @Override
    public int insertBatch(List<LabExpireJob> labExpireJobs) {
        if(CollectionUtils.isNotEmpty(labExpireJobs)){
            return labExpireJobMapper.insertBatch(labExpireJobs);
        }
        return 0;
    }

    @Override
    public List<LabExpireJob> selectByLabId(Long labId) {
        return labExpireJobMapper.selectList(
                new LambdaQueryWrapper<LabExpireJob>()
                        .eq(LabExpireJob::getLabId,labId));
    }

    @Override
    public int deleteByLabId(Long labId) {
        return labExpireJobMapper.delete(
                new LambdaQueryWrapper<LabExpireJob>()
                        .eq(LabExpireJob::getLabId,labId));
    }
}
